package view;

import java.awt.Cursor;
import java.awt.Insets;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;

public class FwkButton extends JButton{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private MouseListener listener;

	public FwkButton(String content, String path){
		this(content, path, 23, 23);
	}
	
	public FwkButton(String content, String path, int width, int hints) {
		super(content, FwkViewsUtils.getIcon(path, width, hints));
		setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
		listener = new RollOverListener();
		this.addMouseListener(listener);
		this.setFocusable(false);
        this.setSelected(false);
        setMargin(new Insets(0, 0, 0, 0));
        this.setContentAreaFilled(false);


	}
	
	private class RollOverListener extends MouseAdapter {

		public void mouseEntered(MouseEvent e) {
			FwkButton b = FwkButton.this;
			b.setContentAreaFilled(true);
			setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
		}

		public void mouseExited(MouseEvent e) {
			FwkButton b = FwkButton.this;
			b.setContentAreaFilled(false);
			setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
		}
	}
}